package code.hkgolden.android.data;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonDeserialize;

import code.hkgolden.android.util.DateDeserializer;

@SuppressWarnings("serial")
@JsonIgnoreProperties(ignoreUnknown = true)
public class Topic implements Serializable, Comparable<Topic> {

	@JsonProperty(value = "Message_ID")
	private Integer id;
	@JsonProperty(value = "Message_Title")
	private String title;
	@JsonProperty(value = "Author_ID")
	private Integer authorId;
	@JsonProperty(value = "Author_Gender")
	private String authorGender;
	@JsonProperty(value = "Author_Name")
	private String authorName;
	@JsonProperty(value = "Last_Reply_Date")
	@JsonDeserialize(using = DateDeserializer.class)
	private Date lastReplyDate;
	@JsonProperty(value = "Message_Status")
	private String status;
	@JsonProperty(value = "Message_Date")
	@JsonDeserialize(using = DateDeserializer.class)
	private Date date;
	@JsonProperty(value = "Message_Body")
	private String body;
	@JsonProperty(value = "Total_Replies")
	private Integer repliesCount;
	@JsonProperty(value = "Rating")
	private Integer rating;
	@JsonProperty(value = "Rating_Good")
	private Integer ratingGood;
	@JsonProperty(value = "Rating_Bad")
	private Integer ratingBad;
	@JsonProperty(value = "messages")
	private Collection<Reply> replies;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Integer getAuthorId() {
		return authorId;
	}

	public void setAuthorId(Integer authorId) {
		this.authorId = authorId;
	}

	public String getAuthorGender() {
		return authorGender;
	}

	public void setAuthorGender(String authorGender) {
		this.authorGender = authorGender;
	}

	public String getAuthorName() {
		return authorName;
	}

	public void setAuthorName(String authorName) {
		this.authorName = authorName;
	}

	public Date getLastReplyDate() {
		return lastReplyDate;
	}

	public void setLastReplyDate(Date lastReplyDate) {
		this.lastReplyDate = lastReplyDate;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public String getBody() {
		return body;
	}

	public void setBody(String body) {
		this.body = body;
	}

	public Integer getRepliesCount() {
		return repliesCount;
	}

	public void setRepliesCount(Integer repliesCount) {
		this.repliesCount = repliesCount;
	}

	public Integer getRating() {
		return rating;
	}

	public void setRating(Integer rating) {
		this.rating = rating;
	}

	public Integer getRatingGood() {
		return ratingGood;
	}

	public void setRatingGood(Integer ratingGood) {
		this.ratingGood = ratingGood;
	}

	public Integer getRatingBad() {
		return ratingBad;
	}

	public void setRatingBad(Integer ratingBad) {
		this.ratingBad = ratingBad;
	}

	public Collection<Reply> getReplies() {
		return replies;
	}

	public void setReplies(Collection<Reply> replies) {
		this.replies = replies;
	}

	public int compareTo(Topic o) {
		final Integer ida = this.rating;
		final Integer id1a = o.rating;
		final Date idb = this.lastReplyDate;
		final Date id1b = o.lastReplyDate;
		return new CompareToBuilder().append(id1a, ida).append(id1b, idb)
				.toComparison();
	}

}
